<!DOCTYPE html>
<html>
<head>
<title>Testing websockets</title>
</head>
<body>
    <div>
        <input type="submit" value="Start" onclick="start()" />
        <input type="submit" value="Stop" onclick="stop()" />
    </div>
    <div id="messages"></div>
    <script type="text/javascript">
		var webSocket = new WebSocket('ws://127.0.0.1:8084/appSocket');
		//var webSocket = new WebSocket('ws://47.110.239.220:8084/appSocket');

        webSocket.onerror = function(event) {
            onError(event)
        };

        webSocket.onopen = function(event) {
            onOpen(event)
        };

        webSocket.onmessage = function(event) {
            onMessage(event)
        };

        function onMessage(event) {
            document.getElementById('messages').innerHTML += '<br />'
                    + event.data;
        }

        function onOpen(event) {
            document.getElementById('messages').innerHTML = 'Connection established';
        }

        function onError(event) {
            alert(event.data);
        }

        function start() {
            webSocket.send('{"url":"Kline","param":{"symbol":20,"period":1}}');
            //webSocket.send('{"url":"StateInfo","param":{"symbol":1}}');
            return false;
        }
		
		function stop(){
			webSocket.close();
		}		
		
    </script>
</body>
</html>